# coding=utf-8
# 编译日期：2022-11-18 01:40:50
# 版权所有：www.i-search.com.cn
import ubpa.init_input as iinput
from ubpa.base_util import StdOutHook, ExceptionHandler
import ubpa.ichrome_firefox as ichrome_firefox
import ubpa.ibox as ibox
import ubpa.iwin as iwin
import ubpa.ibrowse as ibrowse
import ubpa.itools.rpa_fun as rpa_fun
import ubpa.ikeyboard as ikeyboard
import ubpa.itools.rpa_str as rpa_str
import datetime
from dateutil.relativedelta import relativedelta
import ubpa.iexcel as iexcel
import ubpa.itools.rpa_environment as rpa_environment
import time
import pdb
from ubpa.ilog import ILog
from ubpa.base_img import set_img_res_path
import getopt
from sys import argv
import sys
import os
from base_img import *

class ProjectDay4:
     
    def __init__(self,**kwargs):
        self.__logger = ILog(__file__)
        self.path = set_img_res_path(__file__)
        self.robot_no = ''
        self.proc_no = ''
        self.job_no = ''
        self.input_arg = ''
        if('robot_no' in kwargs.keys()):
            self.robot_no = kwargs['robot_no']
        if('proc_no' in kwargs.keys()):
            self.proc_no = kwargs['proc_no']
        if('job_no' in kwargs.keys()):
            self.job_no = kwargs['job_no']
        ILog.JOB_NO, ILog.OLD_STDOUT = self.job_no, sys.stdout
        sys.stdout = StdOutHook(self.job_no, sys.stdout)
        ExceptionHandler.JOB_NO, ExceptionHandler.OLD_STDERR = self.job_no, sys.stderr
        sys.excepthook = ExceptionHandler.handle_exception
        if('input_arg' in kwargs.keys()):
            self.input_arg = kwargs['input_arg']
            if(len(self.input_arg) <= 0):
                self.input_arg = iinput.load_init(__file__)
            if self.input_arg is None:
                sys.exit(0)
        self.Driver=None
      
    def login_in(self):
        #打开浏览器
        self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:login_in,StepNodeTag:2022111717120568810,Title:打开浏览器,Note:')
        self.Driver=tvar_2022111717120568811=ibrowse.open_browser(browser_type='chrome',url='http://123.124.177.30/')
        print('[login_in] [打开浏览器] [SNTag:2022111717120568810]  返回值：[' + str(type(self.Driver)) + ']' + str(self.Driver))
        #打开网站
        self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:login_in,StepNodeTag:2022111717123079715,Title:打开网站,Note:')
        tvar_2022111717123079816=ibrowse.navigate_url(browser=tvar_2022111717120568811,url='http://123.124.177.30/')
        print('[login_in] [打开网站] [SNTag:2022111717123079715]  返回值：[' + str(type(tvar_2022111717123079816)) + ']' + str(tvar_2022111717123079816))
        #最大化窗口
        self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:login_in,StepNodeTag:2022111717134157720,Title:最大化窗口,Note:')
        tvar_2022111717134157721=iwin.do_win_maximize(waitfor=10.000)
        print('[login_in] [最大化窗口] [SNTag:2022111717134157720]  返回值：[' + str(type(tvar_2022111717134157721)) + ']' + str(tvar_2022111717134157721))
        #鼠标点击
        self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:login_in,StepNodeTag:2022111717135853423,Title:鼠标点击,Note:')
        time.sleep(0.4)
        ichrome_firefox.do_click_pos_chrome(waitfor=10.000,run_mode='unctrl',button='left',curson='center',continue_on_error='break',title=r'国家信息安全漏洞库',url=r'http://123.124.177.30/',attrMap={"hasReachedRelativeAncestor":"false","nodeHierarchyInfo":[{"isPresentInSelector":1,"otherAttributes":{},"selectorInfo":{"attributes":{"css-selector":"#a1","id":"a1","tag":"A","xpath":"//*[@id=\"a1\"]"},"index":0,"tagName":"A"}}]})
        # Try异常
        self.__logger.dlogs(job_no=self.job_no, logmsg='Flow:login_in,StepNodeTag:2022111717143066525,Title:Try异常,Note:')
        try:
            #元素是否存在
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:login_in,StepNodeTag:2022111717144058927,Title:元素是否存在,Note:')
            tvar_2022111717145313328=ichrome_firefox.is_element_existed_in_chrome(waitfor=10.000,curson='center',title=r'国家信息安全漏洞库',url=r'http://123.124.177.30/web/vulnerability/querylist.tag',attrMap={"hasReachedRelativeAncestor":"false","nodeHierarchyInfo":[{"isPresentInSelector":1,"otherAttributes":{},"selectorInfo":{"attributes":{"xpath":"//*[@id=\"vulner_0\"]/a[1]"},"index":0,"tagName":"A"}}]})
            print('[login_in] [元素是否存在] [SNTag:2022111717144058927]  返回值：[' + str(type(tvar_2022111717145313328)) + ']' + str(tvar_2022111717145313328))
        except Exception as e:
            #消息框
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:login_in,StepNodeTag:2022111717150312830,Title:消息框,Note:')
            tvar_2022111717150312831=ibox.msgs_box('浏览器打开异常，请核实！',timeout=0)
            print('[login_in] [消息框] [SNTag:2022111717150312830]  返回值：[' + str(type(tvar_2022111717150312831)) + ']' + str(tvar_2022111717150312831))
        finally:
            pass
      
    def read_excel(self):
        excel_path=None
        start_time=None
        count_i=1
        list_i=1
        pag=None
        pag_now=1
        list_count=None
        name=None
        CVE=None
        CVE_str=''
        name_str=''
        #获取环境路径
        self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:2022111717155375535,Title:获取环境路径,Note:')
        excel_path=rpa_environment.get_sys_path(name='Desktop')
        print('[read_excel] [获取环境路径] [SNTag:2022111717155375535]  返回值：[' + str(type(excel_path)) + ']' + str(excel_path))
        #代码块
        self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:2022111717163742442,Title:代码块,Note:')
        excel_path = '{}\ProjectDay4\RPA_第三方资源使用清单_V1.0.xlsx'.format(excel_path)
        #读取整列
        self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:2022111717183228548,Title:读取整列,Note:')
        list_count=tvar_2022111717183228549=iexcel.read_col(path=excel_path,sheet='第三方软件清单',cell='B3')
        print('[read_excel] [读取整列] [SNTag:2022111717183228548]  返回值：[' + str(type(list_count)) + ']' + str(list_count))
        #代码块
        self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:2022111720412281984,Title:代码块,Note:')
        print(len(list_count))
        # For循环
        self.__logger.dlogs(job_no=self.job_no, logmsg='Flow:read_excel,StepNodeTag:2022111717192681055,Title:For循环,Note:')
        for tvar_2022111717192681056 in tvar_2022111717183228549:
            #设置文本
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:2022111717194131158,Title:设置文本,Note:输入漏洞名称')
            ichrome_firefox.set_element_val_chrome(waitfor=10.000,text=tvar_2022111717192681056,title=r'国家信息安全漏洞库',url=r'http://123.124.177.30/web/vulnerability/querylist.tag',attrMap={"hasReachedRelativeAncestor":"false","nodeHierarchyInfo":[{"isPresentInSelector":1,"otherAttributes":{},"selectorInfo":{"attributes":{"css-selector":"#qcvCname","id":"qcvCname","tag":"INPUT","type":"text","xpath":"//*[@id=\"qcvCname\"]"},"index":0,"tagName":"INPUT"}}]})
            #代码块
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:2022111717244931589,Title:代码块,Note:')
            now_time = datetime.datetime.now()
            end_time = str(now_time.date())
            start_time = (now_time + relativedelta(days=-10)).strftime("%Y-%m-%d")
            
            print('开始日期：{}'.format(start_time))
            print('截止日期：{}'.format(end_time))
            #输出
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:2022111717242216786,Title:输出,Note:')
            rpa_str.iprints()
            #鼠标点击
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:2022111717364807996,Title:鼠标点击,Note:')
            ichrome_firefox.do_click_pos_chrome(waitfor=10.000,run_mode='unctrl',button='left',curson='center',continue_on_error='break',title=r'国家信息安全漏洞库',url=r'http://123.124.177.30/web/vulnerability/querylist.tag',attrMap={"hasReachedRelativeAncestor":"false","nodeHierarchyInfo":[{"isPresentInSelector":1,"otherAttributes":{},"selectorInfo":{"attributes":{"css-selector":"#qstartdate","id":"qstartdate","tag":"INPUT","type":"text","xpath":"//*[@id=\"qstartdate\"]"},"index":0,"tagName":"INPUT"}}]})
            #模拟按键
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:2022111717363498995,Title:模拟按键,Note:')
            ikeyboard.key_send_cs(waitfor=10.000,text='20221107')
            #鼠标点击
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:20221117173750730100,Title:鼠标点击,Note:')
            ichrome_firefox.do_click_pos_chrome(waitfor=10.000,run_mode='unctrl',button='left',curson='center',continue_on_error='break',title=r'国家信息安全漏洞库',url=r'http://123.124.177.30/web/vulnerability/querylist.tag',attrMap={"hasReachedRelativeAncestor":"false","nodeHierarchyInfo":[{"isPresentInSelector":1,"otherAttributes":{},"selectorInfo":{"attributes":{"css-selector":"#qcvCnnvdid","id":"qcvCnnvdid","tag":"INPUT","type":"text","xpath":"//*[@id=\"qcvCnnvdid\"]"},"index":0,"tagName":"INPUT"}}]})
            #鼠标点击
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:20221117174418033114,Title:鼠标点击,Note:')
            ichrome_firefox.do_click_pos_chrome(waitfor=10.000,run_mode='unctrl',button='left',curson='center',continue_on_error='break',title=r'国家信息安全漏洞库',url=r'http://123.124.177.30/web/vulnerability/querylist.tag',attrMap={"hasReachedRelativeAncestor":"false","nodeHierarchyInfo":[{"isPresentInSelector":1,"otherAttributes":{},"selectorInfo":{"attributes":{"css-selector":"#qenddate","id":"qenddate","tag":"INPUT","type":"text","xpath":"//*[@id=\"qenddate\"]"},"index":0,"tagName":"INPUT"}}]})
            #模拟按键
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:20221117173756505102,Title:模拟按键,Note:')
            ikeyboard.key_send_cs(waitfor=10.000,text='20221117')
            #鼠标点击
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:20221117174448235118,Title:鼠标点击,Note:')
            ichrome_firefox.do_click_pos_chrome(waitfor=10.000,run_mode='unctrl',button='left',curson='center',continue_on_error='break',title=r'国家信息安全漏洞库',url=r'http://123.124.177.30/web/vulnerability/querylist.tag',attrMap={"hasReachedRelativeAncestor":"false","nodeHierarchyInfo":[{"isPresentInSelector":1,"otherAttributes":{},"selectorInfo":{"attributes":{"css-selector":"#qcvCnnvdid","id":"qcvCnnvdid","tag":"INPUT","type":"text","xpath":"//*[@id=\"qcvCnnvdid\"]"},"index":0,"tagName":"INPUT"}}]})
            #鼠标点击
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:20221117174519786126,Title:鼠标点击,Note:')
            time.sleep(0.4)
            ichrome_firefox.do_click_pos_chrome(waitfor=10.000,run_mode='unctrl',button='left',curson='center',continue_on_error='break',title=r'国家信息安全漏洞库',url=r'http://123.124.177.30/web/vulnerability/querylist.tag',attrMap={"hasReachedRelativeAncestor":"false","nodeHierarchyInfo":[{"isPresentInSelector":1,"otherAttributes":{},"selectorInfo":{"attributes":{"aaname":"搜索","css-selector":"#queryform > table:nth-child(11) > tbody:nth-child(1) > tr:nth-child(5) > td:nth-child(2) > a:nth-child(1)","parentid":"queryform","tag":"A","xpath":"//*[@id=\"queryform\"]/table[1]/tbody[1]/tr[5]/td[2]/a[1]"},"index":0,"tagName":"A"}}]})
            #元素是否存在
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:2022111718115247841,Title:元素是否存在,Note:')
            tvar_2022111718123760642=ichrome_firefox.is_element_existed_in_chrome(waitfor=5.000,curson='center',title=r'国家信息安全漏洞库',url=r'http://123.124.177.30/web/vulnerability/queryLds.tag',attrMap={"hasReachedRelativeAncestor":"false","nodeHierarchyInfo":[{"isPresentInSelector":1,"otherAttributes":{},"selectorInfo":{"attributes":{"css-selector":"html:nth-child(1) > body:nth-child(2) > div:nth-child(7) > div:nth-child(1)","tag":"DIV","xpath":"/html/body/div[4]/div[1]"},"index":0,"tagName":"DIV"}}]})
            print('[read_excel] [元素是否存在] [SNTag:2022111718115247841]  返回值：[' + str(type(tvar_2022111718123760642)) + ']' + str(tvar_2022111718123760642))
            # IF分支
            self.__logger.dlogs(job_no=self.job_no, logmsg='Flow:read_excel,StepNodeTag:2022111718171803945,Title:IF分支,Note:假为没有漏洞，真需要分两种情况。')
            if tvar_2022111718123760642:
                # Try异常
                self.__logger.dlogs(job_no=self.job_no, logmsg='Flow:read_excel,StepNodeTag:20221117195021201120,Title:Try异常,Note:')
                try:
                    #获取文本
                    self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:2022111718344516478,Title:获取文本,Note:')
                    tvar_2022111718344825279=ichrome_firefox.get_element_val_chrome(waitfor=0.800,title=r'国家信息安全漏洞库',url=r'http://123.124.177.30/web/vulnerability/queryLds.tag',continue_on_error='break',attrMap={"hasReachedRelativeAncestor":"false","nodeHierarchyInfo":[{"isPresentInSelector":1,"otherAttributes":{},"selectorInfo":{"attributes":{"xpath":"/html/body/div[4]/div[1]/div[1]/div[1]/div[3]/a[1]"},"index":0,"tagName":"A"}}]})
                    print('[read_excel] [获取文本] [SNTag:2022111718344516478]  返回值：[' + str(type(tvar_2022111718344825279)) + ']' + str(tvar_2022111718344825279))
                    #split
                    self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:2022111718360178584,Title:split,Note:')
                    pag=rpa_str.split(string=tvar_2022111718344825279,str='：',num=1)
                    print('[read_excel] [split] [SNTag:2022111718360178584]  返回值：[' + str(type(pag)) + ']' + str(pag))
                    #代码块
                    self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:2022111718390938491,Title:代码块,Note:')
                    print('总计{}条'.format(pag[1]))
                    #获取文本
                    self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:20221117174808155140,Title:获取文本,Note:')
                    tvar_20221117174819550141=ichrome_firefox.get_element_val_chrome(waitfor=10.000,title=r'国家信息安全漏洞库',url=r'http://123.124.177.30/web/vulnerability/queryLds.tag',continue_on_error='break',attrMap={
                        "hasReachedRelativeAncestor": "false",
                        "nodeHierarchyInfo": [
                            {
                                "isPresentInSelector": 1,
                                "otherAttributes": {
                                },
                                "selectorInfo": {
                                    "attributes": {
                                        "xpath": "//*[@id=\"vulner_{}\"]/a[1]".format(count_i-1)
                                    },
                                    "index": 0,
                                    "tagName": "A"
                                }
                            }
                        ]
                    })
                    print('[read_excel] [获取文本] [SNTag:20221117174808155140]  返回值：[' + str(type(tvar_20221117174819550141)) + ']' + str(tvar_20221117174819550141))
                    # While循环
                    self.__logger.dlogs(job_no=self.job_no, logmsg='Flow:read_excel,StepNodeTag:2022111718442455197,Title:While循环,Note:')
                    while int(pag_now) <= int(pag[1]):
                        #鼠标点击
                        self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:20221117175546021150,Title:鼠标点击,Note:')
                        time.sleep(0.2)
                        ichrome_firefox.do_click_pos_chrome(waitfor=10.000,run_mode='unctrl',button='left',curson='center',continue_on_error='break',title=r'国家信息安全漏洞库',url=r'http://123.124.177.30/web/vulnerability/queryLds.tag',attrMap={
                            "hasReachedRelativeAncestor": "false",
                            "nodeHierarchyInfo": [
                                {
                                    "isPresentInSelector": 1,
                                    "otherAttributes": {
                                    },
                                    "selectorInfo": {
                                        "attributes": {
                                            "xpath": "//*[@id=\"vulner_{}\"]/a[1]".format(count_i-1)
                                        },
                                        "index": 0,
                                        "tagName": "A"
                                    }
                                }
                            ]
                        })
                        #获取文本
                        self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:20221117175619409152,Title:获取文本,Note:漏洞标题')
                        time.sleep(0.2)
                        name=ichrome_firefox.get_element_val_chrome(waitfor=10.000,title=r'国家信息安全漏洞库',url=r'http://123.124.177.30/web/xxk/ldxqById.tag?CNNVD=CNNVD-202211-*',continue_on_error='break',attrMap={"hasReachedRelativeAncestor":"false","nodeHierarchyInfo":[{"isPresentInSelector":1,"otherAttributes":{},"selectorInfo":{"attributes":{"xpath":"/html/body/div[4]/div[1]/div[1]/div[2]/h2[1]"},"index":0,"tagName":"H2"}}]})
                        print('[read_excel] [获取文本] [SNTag:20221117175619409152]  返回值：[' + str(type(name)) + ']' + str(name))
                        #代码块
                        self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:20221117205559191109,Title:代码块,Note:')
                        name_str = name_str + name+':'
                        #获取文本
                        self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:20221117180546874168,Title:获取文本,Note:CVE编号')
                        time.sleep(0.2)
                        CVE=ichrome_firefox.get_element_val_chrome(waitfor=10.000,title=r'国家信息安全漏洞库',url=r'http://123.124.177.30/web/xxk/ldxqById.tag?CNNVD=CNNVD-202211-*',continue_on_error='break',attrMap={"hasReachedRelativeAncestor":"false","nodeHierarchyInfo":[{"isPresentInSelector":1,"otherAttributes":{},"selectorInfo":{"attributes":{"xpath":"/html/body/div[4]/div[1]/div[1]/div[2]/ul[1]/li[3]/a[1]"},"index":0,"tagName":"A"}}]})
                        print('[read_excel] [获取文本] [SNTag:20221117180546874168]  返回值：[' + str(type(CVE)) + ']' + str(CVE))
                        #代码块
                        self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:20221117205834204121,Title:代码块,Note:')
                        print(int(pag_now))
                        print(int(pag[1]))
                        CVE_str = CVE_str + CVE +':'
                        # IF分支
                        self.__logger.dlogs(job_no=self.job_no, logmsg='Flow:read_excel,StepNodeTag:20221117212242508149,Title:IF分支,Note:')
                        if int(pag_now) == int(pag[1]):
                            # Break中断
                            self.__logger.dlogs(job_no=self.job_no, logmsg='Flow:read_excel,StepNodeTag:20221117212306971151,Title:Break中断,Note:')
                            break
                        else:
                            #设置文本
                            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:20221117184542600102,Title:设置文本,Note:输入漏洞名称')
                            time.sleep(0.2)
                            ichrome_firefox.set_element_val_chrome(waitfor=10.000,text=tvar_2022111717192681056,title=r'国家信息安全漏洞库',url=r'http://123.124.177.30/web/xxk/ldxqById.tag?CNNVD=CNNVD-202211-*',attrMap={"hasReachedRelativeAncestor":"false","nodeHierarchyInfo":[{"isPresentInSelector":1,"otherAttributes":{},"selectorInfo":{"attributes":{"css-selector":"#qcvCname","id":"qcvCname","tag":"INPUT","type":"text","xpath":"//*[@id=\"qcvCname\"]"},"index":0,"tagName":"INPUT"}}]})
                            #代码块
                            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:20221117184542600109,Title:代码块,Note:')
                            time.sleep(0.4)
                            now_time = datetime.datetime.now()
                            end_time = str(now_time.date())
                            start_time = (now_time + relativedelta(days=-10)).strftime("%Y-%m-%d")
                            
                            print('开始日期：{}'.format(start_time))
                            print('截止日期：{}'.format(end_time))
                            #输出
                            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:20221117184542600106,Title:输出,Note:')
                            rpa_str.iprints()
                            #鼠标点击
                            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:20221117184542600107,Title:鼠标点击,Note:')
                            ichrome_firefox.do_click_pos_chrome(waitfor=10.000,run_mode='unctrl',button='left',curson='center',continue_on_error='break',title=r'国家信息安全漏洞库',url=r'http://123.124.177.30/web/xxk/ldxqById.tag?CNNVD=CNNVD-202211-*',attrMap={"hasReachedRelativeAncestor":"false","nodeHierarchyInfo":[{"isPresentInSelector":1,"otherAttributes":{},"selectorInfo":{"attributes":{"xpath":"//*[@id=\"qstartdate\"]"},"index":0,"tagName":"INPUT"}}]})
                            #模拟按键
                            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:20221117184542600103,Title:模拟按键,Note:')
                            time.sleep(0.2)
                            ikeyboard.key_send_cs(waitfor=10.000,text='20221107')
                            #鼠标点击
                            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:20221117184542600104,Title:鼠标点击,Note:')
                            time.sleep(0.2)
                            ichrome_firefox.do_click_pos_chrome(waitfor=10.000,run_mode='unctrl',button='left',curson='center',continue_on_error='break',title=r'国家信息安全漏洞库',url=r'http://123.124.177.30/web/xxk/ldxqById.tag?CNNVD=CNNVD-202211-*',attrMap={"hasReachedRelativeAncestor":"false","nodeHierarchyInfo":[{"isPresentInSelector":1,"otherAttributes":{},"selectorInfo":{"attributes":{"css-selector":"#qcvCnnvdid","id":"qcvCnnvdid","tag":"INPUT","type":"text","xpath":"//*[@id=\"qcvCnnvdid\"]"},"index":0,"tagName":"INPUT"}}]})
                            #鼠标点击
                            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:20221117184542600101,Title:鼠标点击,Note:')
                            time.sleep(0.2)
                            ichrome_firefox.do_click_pos_chrome(waitfor=10.000,run_mode='unctrl',button='left',curson='center',continue_on_error='break',title=r'国家信息安全漏洞库',url=r'http://123.124.177.30/web/xxk/ldxqById.tag?CNNVD=CNNVD-202211-*',attrMap={"hasReachedRelativeAncestor":"false","nodeHierarchyInfo":[{"isPresentInSelector":1,"otherAttributes":{},"selectorInfo":{"attributes":{"css-selector":"#qenddate","id":"qenddate","tag":"INPUT","type":"text","xpath":"//*[@id=\"qenddate\"]"},"index":0,"tagName":"INPUT"}}]})
                            #模拟按键
                            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:20221117184542600105,Title:模拟按键,Note:')
                            time.sleep(0.2)
                            ikeyboard.key_send_cs(waitfor=10.000,text='20221117')
                            #鼠标点击
                            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:20221117184542600108,Title:鼠标点击,Note:')
                            time.sleep(0.2)
                            ichrome_firefox.do_click_pos_chrome(waitfor=10.000,run_mode='unctrl',button='left',curson='center',continue_on_error='break',title=r'国家信息安全漏洞库',url=r'http://123.124.177.30/web/xxk/ldxqById.tag?CNNVD=CNNVD-202211-*',attrMap={"hasReachedRelativeAncestor":"false","nodeHierarchyInfo":[{"isPresentInSelector":1,"otherAttributes":{},"selectorInfo":{"attributes":{"css-selector":"#qcvCnnvdid","id":"qcvCnnvdid","tag":"INPUT","type":"text","xpath":"//*[@id=\"qcvCnnvdid\"]"},"index":0,"tagName":"INPUT"}}]})
                            #鼠标点击
                            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:20221117184542600100,Title:鼠标点击,Note:')
                            time.sleep(0.2)
                            ichrome_firefox.do_click_pos_chrome(waitfor=10.000,run_mode='unctrl',button='left',curson='center',continue_on_error='break',title=r'国家信息安全漏洞库',url=r'http://123.124.177.30/web/xxk/ldxqById.tag?CNNVD=CNNVD-202211-*',attrMap={"hasReachedRelativeAncestor":"false","nodeHierarchyInfo":[{"isPresentInSelector":1,"otherAttributes":{},"selectorInfo":{"attributes":{"aaname":"搜索","css-selector":"#queryform > table:nth-child(3) > tbody:nth-child(1) > tr:nth-child(5) > td:nth-child(2) > a:nth-child(1)","parentid":"queryform","tag":"A","xpath":"//*[@id=\"queryform\"]/table[1]/tbody[1]/tr[5]/td[2]/a[1]"},"index":0,"tagName":"A"}}]})
                            #自加
                            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:20221117185430330139,Title:自加,Note:')
                            count_i=rpa_fun.rpa_self_add(x=count_i)
                            print('[read_excel] [自加] [SNTag:20221117185430330139]  返回值：[' + str(type(count_i)) + ']' + str(count_i))
                            #自加
                            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:20221117213116958154,Title:自加,Note:')
                            pag_now=rpa_fun.rpa_self_add(x=pag_now)
                            print('[read_excel] [自加] [SNTag:20221117213116958154]  返回值：[' + str(type(pag_now)) + ']' + str(pag_now))
                            # Continue继续
                            self.__logger.dlogs(job_no=self.job_no, logmsg='Flow:read_excel,StepNodeTag:20221117185403010137,Title:Continue继续,Note:')
                            continue
                    #代码块
                    self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:2022111721423701291,Title:代码块,Note:')
                    print(name_str)
                    print(CVE_str)
                    #单元格写入
                    self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:20221117175716007158,Title:单元格写入,Note:')
                    time.sleep(0.2)
                    tvar_20221117175716023159=iexcel.write_cell(path=excel_path,text=name_str,sheet='第三方软件清单',cell='O'+str(list_i+2))
                    print('[read_excel] [单元格写入] [SNTag:20221117175716007158]  返回值：[' + str(type(tvar_20221117175716023159)) + ']' + str(tvar_20221117175716023159))
                    #单元格写入
                    self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:20221117180606852171,Title:单元格写入,Note:')
                    time.sleep(0.2)
                    tvar_20221117180606852172=iexcel.write_cell(path=excel_path,text=CVE_str,sheet='第三方软件清单',cell='P'+str(list_i+2))
                    print('[read_excel] [单元格写入] [SNTag:20221117180606852171]  返回值：[' + str(type(tvar_20221117180606852172)) + ']' + str(tvar_20221117180606852172))
                    #关闭浏览器
                    self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:20221117224620889132,Title:关闭浏览器,Note:')
                    tvar_20221117224620889133=ibrowse.close_web_browser(browser=self.Driver)
                    print('[read_excel] [关闭浏览器] [SNTag:20221117224620889132]  返回值：[' + str(type(tvar_20221117224620889133)) + ']' + str(tvar_20221117224620889133))
                    #代码块
                    self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:20221117233044003202,Title:代码块,Note:')
                    name_str = ''
                    CVE_str = ''
                    pag_now = 1
                    count_i = 1
                    pag = 0
                    #自加
                    self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:20221117195857111139,Title:自加,Note:')
                    list_i=rpa_fun.rpa_self_add(x=list_i)
                    print('[read_excel] [自加] [SNTag:20221117195857111139]  返回值：[' + str(type(list_i)) + ']' + str(list_i))
                    #子流程
                    self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:20221117224625288140,Title:子流程,Note:')
                    tvar202211172246252881401=self.login_in()
                    print('[read_excel] [子流程] [SNTag:20221117224625288140]  返回值：[' + str(type(tvar202211172246252881401)) + ']' + str(tvar202211172246252881401))
                    # Continue继续
                    self.__logger.dlogs(job_no=self.job_no, logmsg='Flow:read_excel,StepNodeTag:20221117224713190146,Title:Continue继续,Note:')
                    continue
                except Exception as e:
                    #消息框
                    self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:20221117224945331151,Title:消息框,Note:')
                    tvar_20221117224945331152=ibox.msgs_box('该软件未发现漏洞！',timeout=1)
                    print('[read_excel] [消息框] [SNTag:20221117224945331151]  返回值：[' + str(type(tvar_20221117224945331152)) + ']' + str(tvar_20221117224945331152))
                    #关闭浏览器
                    self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:20221117195105675124,Title:关闭浏览器,Note:')
                    tvar_20221117195105675125=ibrowse.close_web_browser(browser=self.Driver)
                    print('[read_excel] [关闭浏览器] [SNTag:20221117195105675124]  返回值：[' + str(type(tvar_20221117195105675125)) + ']' + str(tvar_20221117195105675125))
                    #自加
                    self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:20221118002853775146,Title:自加,Note:')
                    list_i=rpa_fun.rpa_self_add(x=list_i)
                    print('[read_excel] [自加] [SNTag:20221118002853775146]  返回值：[' + str(type(list_i)) + ']' + str(list_i))
                    #代码块
                    self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:20221118005442597120,Title:代码块,Note:')
                    name_str = ''
                    CVE_str = ''
                    pag_now = 1
                    count_i = 1
                    pag = 0
                    #子流程
                    self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:20221117230847980182,Title:子流程,Note:')
                    tvar202211172308479801821=self.login_in()
                    print('[read_excel] [子流程] [SNTag:20221117230847980182]  返回值：[' + str(type(tvar202211172308479801821)) + ']' + str(tvar202211172308479801821))
                    # Continue继续
                    self.__logger.dlogs(job_no=self.job_no, logmsg='Flow:read_excel,StepNodeTag:20221118002844739141,Title:Continue继续,Note:')
                    continue
                finally:
                    pass
            else:
                #消息框
                self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:20221117224904807148,Title:消息框,Note:')
                tvar_20221117224904807149=ibox.msgs_box('该软件未发现漏洞！',timeout=1)
                print('[read_excel] [消息框] [SNTag:20221117224904807148]  返回值：[' + str(type(tvar_20221117224904807149)) + ']' + str(tvar_20221117224904807149))
                #关闭浏览器
                self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:2022111719394264497,Title:关闭浏览器,Note:')
                tvar_2022111719394264598=ibrowse.close_web_browser(browser=self.Driver)
                print('[read_excel] [关闭浏览器] [SNTag:2022111719394264497]  返回值：[' + str(type(tvar_2022111719394264598)) + ']' + str(tvar_2022111719394264598))
                #自加
                self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:20221118002247931125,Title:自加,Note:')
                list_i=rpa_fun.rpa_self_add(x=list_i)
                print('[read_excel] [自加] [SNTag:20221118002247931125]  返回值：[' + str(type(list_i)) + ']' + str(list_i))
                #单元格写入
                self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:20221117230622061169,Title:单元格写入,Note:')
                time.sleep(0.2)
                tvar_20221117230622061170=iexcel.write_cell(path=excel_path,text='您提交的相关表单数据字符含有非法字符！',sheet='第三方软件清单',cell='P'+str(list_i+1))
                print('[read_excel] [单元格写入] [SNTag:20221117230622061169]  返回值：[' + str(type(tvar_20221117230622061170)) + ']' + str(tvar_20221117230622061170))
                #代码块
                self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:20221118005454526127,Title:代码块,Note:')
                name_str = ''
                CVE_str = ''
                pag_now = 1
                count_i = 1
                pag = 0
                #子流程
                self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:read_excel,StepNodeTag:20221117195458232135,Title:子流程,Note:')
                tvar202211171954582321351=self.login_in()
                print('[read_excel] [子流程] [SNTag:20221117195458232135]  返回值：[' + str(type(tvar202211171954582321351)) + ']' + str(tvar202211171954582321351))
                # Continue继续
                self.__logger.dlogs(job_no=self.job_no, logmsg='Flow:read_excel,StepNodeTag:20221118002715706138,Title:Continue继续,Note:')
                continue
      
    def Main(self):
        #子流程
        self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:Main,StepNodeTag:20221117174706550133,Title:子流程,Note:')
        tvar202211171747065501331=self.login_in()
        print('[Main] [子流程] [SNTag:20221117174706550133]  返回值：[' + str(type(tvar202211171747065501331)) + ']' + str(tvar202211171747065501331))
        #子流程
        self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:Main,StepNodeTag:20221117174715378135,Title:子流程,Note:')
        tvar202211171747153781351=self.read_excel()
        print('[Main] [子流程] [SNTag:20221117174715378135]  返回值：[' + str(type(tvar202211171747153781351)) + ']' + str(tvar202211171747153781351))
 
if __name__ == '__main__':
    ILog.begin_init()
    robot_no = ''
    proc_no = ''
    job_no = ''
    input_arg = ''
    try:
        argv = sys.argv[1:]
        opts, args = getopt.getopt(argv,"hr:p:j:i:",["robot = ","proc = ","job = ","input = "])
    except getopt.GetoptError:
        print ('robot.py -r <robot> -p <proc> -j <job>')
    for opt, arg in opts:
        if opt == '-h':
            print ('robot.py -r <robot> -p <proc> -j <job>')
        elif opt in ("-r", "--robot"):
            robot_no = arg
        elif opt in ("-p", "--proc"):
            proc_no = arg
        elif opt in ("-j", "--job"):
            job_no = arg
        elif opt in ("-i", "--input"):
            input_arg = arg
    pro = ProjectDay4(robot_no=robot_no,proc_no=proc_no,job_no=job_no,input_arg=input_arg)
    pro.Main()
